package com.example.demo.service;

import com.example.demo.mapper.UserMapper;
import com.example.demo.model.UserInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserService {
    @Autowired
    private UserMapper userMapper;
    // 用户注册
    public int reg(String username, String password) {
        return userMapper.reg(username, password);
    }
    // 通过名称查询用户-->用于登录的验证
    public UserInfo selectByUsername(String username) {
        return userMapper.selectByUsername(username);
    }

    public UserInfo getAddress(int uid) {
        return userMapper.getAddress(uid);
    }

    public UserInfo getUserInfo(int uid) {
        return userMapper.getUserInfo(uid);}

    public int changePassword(String newPassword,int uid) {
        return userMapper.changePassword(newPassword,uid);
    }

    public int changeUserInfo(UserInfo userInfo) {
        return userMapper.changeUserInfo(userInfo);
    }

}
